package com.gitee.mocoffee.embedzk.spring;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

import com.gitee.mocoffee.embedzk.EmbedZK;

import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;

/**
 * @author lijia
 */
@Configuration
@ConditionalOnProperty(name = "app.embedzk.enable", havingValue = "true")
@FieldDefaults(level = AccessLevel.PRIVATE)
public class EmbedZKConfig {
    @Value("${app.embedzk.port}")
    Integer port;
    @Value("${app.embedzk.path}")
    String  path;

    @Bean(initMethod = "start")
    @Order(Integer.MIN_VALUE)
    public EmbedZK getEmbedzk() throws Exception {
        return new EmbedZK(port, path);
    }
}
